<?php
/* @var $this StaticPagesController */
/* @var $model StaticPages */
/* @var $form CActiveForm */

?>
<style type="text/css">
.row { margin-left:0; }
</style>
<script type="text/javascript">

function toggleCodeUpload(str)
{
	if(str == 'image')
	{
		$('#file').show();
	}
	else if(str== "none")
	{
		$('#file').hide();
		$('#f').val('');
	}
}

</script>
<div class="form">

<?php



 /*$form=$this->beginWidget('CActiveForm', array(
	'id'=>'static-pages-form',
	'htmlOptions'=>array('onsubmit'=>'return validate();','enctype'=>'multipart/form-data'),
	'enableAjaxValidation'=>false,
)); */
$form=$this->beginWidget('CActiveForm', array(
	'id'=>'static-pages-form',
	'htmlOptions'=>array('enctype'=>'multipart/form-data'),
	'enableAjaxValidation'=>false,
));
?>

	<p class="help-block">Fields with <span class="required">*</span> are required.</p>

	<span class=" alert-block alert-error "> <?php echo $form->errorSummary($model); ?></span>

	
	<div class="row">
		<?php echo $form->labelEx($model,'category_id'); ?>
		<?php 
				$list = Terms::model()->getList("ALL", array());
				echo $form->dropDownList($model,'category_id', CHtml::listData($list, 'termID', 'term_name'),array('prompt'=>'--Select Term--')); 
		?>
		<?php  echo $form->error($model,'category_id'); ?>
	</div>

	

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>


	<div class="row">
		<?php echo $form->labelEx($model,'content'); ?>
		<?php 
		$this->widget('application.extensions.ckeditor.CKEditor', array(
			'model'=>$model,
			'attribute'=>'content',
			'language'=>'en',
			'editorTemplate'=>'full',
			)); 
			?>
		<?php echo $form->error($model,'content'); ?>
	</div>
   </br>
    <div class="row">
		<?php 
		//$model->type = 'image';
		if($model->staticpage_id == "")
		{
		$model->type = 'none';
		}
		echo $form->labelEx($model,'type'); ?>
		<?php echo $form->radioButtonList($model,'type',array('none'=>'none','image'=>'Upload image') ,array('labelOptions'=>array('style'=>'display:inline'), // add this code
    'separator'=>'  ','onclick'=>'toggleCodeUpload(this.value);')); ?>
		<?php echo $form->error($model,'type'); ?>
	</div>
	</br>
	<div id="file">
		<?php echo $form->labelEx($model,'attachment'); ?>
		<?php echo $form->fileField($model,'attachment',array('id'=>'f')); ?>
		<?php echo $form->error($model,'attachment'); ?>
	</div>	
	
	
	<div class="row">
		<?php echo $form->labelEx($model,'tags'); ?>
		<?php echo $form->textField($model,'tags',array('size'=>60,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'tags'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'status'); ?>	
		<?php  echo $form->radioButtonList($model,'status',array(1=>'Enable',0=>'Disable'),array(
    'labelOptions'=>array('style'=>'display:inline'), // add this code
    'separator'=>'  ',
	)); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

	</br>
	
	<div class="row form-actions">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array('class' => 'btn btn-primary')); ?>
		<?php echo CHtml::button('Cancel', array('submit' => array('admin'),'class' => 'btn btn-primary')); ?>
		
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
<script>
var str=$('input[name="StaticPages[type]"]').filter(':checked').val();
toggleCodeUpload(str);


</script>